package org.msn.gui.controller;

import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.input.MouseEvent;
import javafx.stage.Stage;
import org.msn.dto.JoinRoomDTO;
import org.msn.gui.constant.APIConstant;
import org.msn.gui.init.ShowAllRoomInit;

import java.io.IOException;

public class ShowAllRoomController extends ShowAllRoomInit {
    public void createRoom(MouseEvent mouseEvent) throws IOException {
        Stage stage = new Stage();
        Parent root = FXMLLoader.load(getClass().getResource("/fxml/createRoomFxml.fxml"));
        stage.setScene(new Scene(root, 300, 100));
        exportAddRoomStage = stage;
        stage.show();
    }

    public void joinRoom(MouseEvent mouseEvent) {
        // 发起请求
        sendJoinRoom(ctx, JoinRoomDTO
                .builder()
                .roomName(ShowAllRoomInit.exportSelectRoomName)
                .username((String) APIConstant.CONFIG.get("name"))
                .build());
    }
}
